use serde::Deserialize;

fn default_secret() -> String {
    "027".to_string()
}

fn default_login_view() -> String {
    "/auth/login".to_string()
}

fn default_path() -> String {
    "/".to_string()
}

fn default_true() -> bool {
    true
}

#[derive(Debug, Clone, Deserialize)]
pub struct LoginmanagerConfig {
    #[serde(default = "default_secret")]
    pub secret: String,
    #[serde(default = "default_login_view")]
    pub login_view: String,
    #[serde(default = "default_path")]
    pub path: String,
    #[serde(default = "default_true")]
    pub secure: bool,
    #[serde(default = "default_true")]
    pub redirect: bool,
}

impl Default for LoginmanagerConfig {
    fn default() -> Self {
        Self {
            secret: default_secret(),
            secure: true,
            redirect: true,
            login_view: default_login_view(),
            path: default_path(),
        }
    }
}
